/*
 * change class => change color
 */

function changeClass(idLabel, idCheckbox) {
	if (idLabel == 'idLabelQuantite') {
		if (document.getElementById(idCheckbox).checked) {
			document.getElementById(idLabel).className = "labelChanged";
		} else {
			document.getElementById(idLabel).className = "labelOriginal";
		}
	}else if(idLabel == 'idLabelProduit'){
		if (document.getElementById(idCheckbox).checked) {
			document.getElementById(idLabel).className = "labelChanged";
		} else {
			document.getElementById(idLabel).className = "labelOriginal";
			document.getElementById('idLabelFournisseur').className = "labelOriginal";
			document.getElementById('idCheckboxFournisseur').checked = false;
			document.getElementById('idLabelCategorie').className = "labelOriginal";
			document.getElementById('idCheckboxCategorie').checked = false;
		}
	}else if(idLabel == 'idLabelFournisseur' || idLabel == 'idLabelCategorie'){
		if (document.getElementById(idCheckbox).checked) {
			document.getElementById(idLabel).className = "labelChanged";
			document.getElementById('idLabelProduit').className = "labelChanged";
			document.getElementById('idCheckboxProduit').checked = true;
			
		} else {
			document.getElementById(idLabel).className = "labelOriginal";
		}
	}else if(idLabel == 'idLabelMagazin'){
		if (document.getElementById(idCheckbox).checked) {
			document.getElementById(idLabel).className = "labelChanged";
		} else {
			document.getElementById(idLabel).className = "labelOriginal";
			document.getElementById('idLabelVille').className = "labelOriginal";
			document.getElementById('idCheckboxVille').checked = false;
			document.getElementById('idLabelRegion').className = "labelOriginal";
			document.getElementById('idCheckboxRegion').checked = false;
		}
	}else if(idLabel == 'idLabelVille'){
		if (document.getElementById(idCheckbox).checked) {
			document.getElementById(idLabel).className = "labelChanged";
			document.getElementById('idLabelMagazin').className = "labelChanged";
			document.getElementById('idCheckboxMagazin').checked = true;
			
		} else {
			document.getElementById(idLabel).className = "labelOriginal";
			document.getElementById('idLabelRegion').className = "labelOriginal";
			document.getElementById('idCheckboxRegion').checked = false;
		}
	}else if(idLabel == 'idLabelRegion'){
		if (document.getElementById(idCheckbox).checked) {
			document.getElementById(idLabel).className = "labelChanged";
			document.getElementById('idLabelVille').className = "labelChanged";
			document.getElementById('idCheckboxVille').checked = true;
			document.getElementById('idLabelMagazin').className = "labelChanged";
			document.getElementById('idCheckboxMagazin').checked = true;
			
		} else {
			document.getElementById(idLabel).className = "labelOriginal";

		}
	}else if(idLabel == 'idLabelDate'){
		if (document.getElementById(idCheckbox).checked) {
			document.getElementById(idLabel).className = "labelChanged";
		} else {
			document.getElementById(idLabel).className = "labelOriginal";
			document.getElementById('idLabelMois').className = "labelOriginal";
			document.getElementById('idCheckboxMois').checked = false;
		}
	}else if(idLabel == 'idLabelMois'){
		if (document.getElementById(idCheckbox).checked) {
			document.getElementById(idLabel).className = "labelChanged";
			document.getElementById('idLabelDate').className = "labelChanged";
			document.getElementById('idCheckboxDate').checked = true;
		} else {
			document.getElementById(idLabel).className = "labelOriginal";

		}
	}
}



/*
 * check if there is one or more classifier selected
 */
function checkClassifier() {
	var form = document.forms.edd;
	var inputs = form.getElementsByTagName("input");
	var count = 0;
	for (i = 0; i < inputs.length; i++) {
		if (inputs[i].type == "checkbox" && inputs[i].checked == true) {
			count++;
		}
	}

	if (count == 0) {
		alert("Vous devez choisir au  moins un classifieur !");
	}else{
		document.getElementById("idEtape1").disabled = true;
		for (i = 0; i < inputs.length; i++) {
			if (inputs[i].type == "checkbox") {
				inputs[i].disabled = true;
			}
		}
		document.getElementById("idCheckboxQuantite").disabled = false;
	}
}

/*
 * check if there is one or more mesure selected
 */
function checkMesure() {
	var form = document.forms.edd;
	if (document.getElementById("idCheckboxQuantite").checked == false) {
		alert("Vous devez choisir au  moins une mesure !");
	}else{
		document.getElementById("idEtape2").disabled = true;
		document.getElementById("idCheckboxQuantite").disabled = true;
	}

}

/*
 * 
 */
function activateRestrictionList(idCheckboxProduit, idListProduit) {
	if (document.getElementById(idCheckboxProduit).checked) {
		document.getElementById(idListProduit).disabled = false;
	} else {
		document.getElementById(idListProduit).disabled = true;
	}

}